<template>
	<view class="container">
		
		
		<view class="tui-box">
			
			<view class="tui-top tui-goods-info">
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>订单编号</view>
						<view>SN{{orderInfo.add_date}}{{orderInfo.id}}</view>
					</view>
				</tui-list-cell>
				
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>商品名称</view>
						<view>{{goodsInfo.name}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>支付积分</view>
						<view>{{orderInfo.goods_point}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>订单状态</view>
						<view>{{orderInfo.status_name}}</view>
					</view>
				</tui-list-cell>
				
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>下单时间</view>
						<view>{{orderInfo.add_time}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>收货人</view>
						<view>{{shipInfo.name}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>收货电话</view>
						<view>{{shipInfo.phone}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>收货地址</view>
						<view>{{shipInfo.address}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>发货时间</view>
						<view>{{orderInfo.ship_time}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>物流公司</view>
						<view>{{shipInfo.express_code}}</view>
					</view>
				</tui-list-cell>
				<tui-list-cell :hover="false">
					<view class="tui-padding tui-flex">
						<view>物流单号</view>
						<view>{{shipInfo.ship_code}}</view>
					</view>
				</tui-list-cell>
				
			</view>
			
			
			<block v-if="orderInfo.status != 1">
				
				<view class="tui-edit" @click="postOrderFinish()">
					<tui-button type="green" width="500rpx" height="80rpx" :size="30">确认收货</tui-button>
				</view>
				
			</block>
			
		</view>
		<view class="tui-safe-area"></view>
		
		<footer-menu></footer-menu>
	</view>
</template>

<script>
	import footerMenu from "@/components/footer-menu.vue"
	import tuiIcon from "@/components/thorui/tui-icon/tui-icon.vue"
	import tuiButton from "@/components/thorui/tui-button/tui-button"
	import tuiListCell from "@/components/thorui/tui-list-cell/tui-list-cell"
	import tuiBottomPopup from "@/components/thorui/tui-bottom-popup/tui-bottom-popup"
	import tuiModal from "@/components/thorui/tui-modal/tui-modal"
	export default {
		components: {
			tuiButton,
			tuiListCell,
			tuiBottomPopup,
			tuiModal,
			footerMenu,
			tuiIcon,
		},
		data() {
			return {
				hasCoupon: true,
				insufficient: false,
				
				orderId: 0,
				orderInfo: [],
				goodsInfo: [],
				postInfo: [],
				shipInfo: [],
				
				canApplyRefund: false,	//是否可以申请退款 默认不可以
				applyModal: false,
				applyReason: ""	,		//退款原因
			}
		},
		
		methods: {
			

			//得到订单的详情
			getOrderInfo: function() {
				uni.request({
					url: this.$apiUrl + '/api/point/orderInfo',
					header: {
						'userId': uni.getStorageSync('userId'),
						'userToken': uni.getStorageSync('userToken'),
						'shopId': uni.getStorageSync('shopId'),
					},
					data: { order_id: this.orderId},
					success: (res) => {
						let resData = res.data['data'];
						let resError = res.data['error'];
						if(resError) { this.tui.toast("数据请求失败~"); return; }
						this.orderInfo = resData.order_info;
						this.goodsInfo = resData.goods_info;
						this.shipInfo = resData.ship_info;
					}
				});
			},
			
			
			//确认订单完成
			postOrderFinish: function() {
				uni.request({
					url: this.$apiUrl + '/api/point/orderFinish',
					header: {
						'userId': uni.getStorageSync('userId'),
						'userToken': uni.getStorageSync('userToken'),
						'shopId': uni.getStorageSync('shopId'),
					},
					data: {
						order_id: this.orderId,
					},
					success: (res) => {
						let resMsg = res.data['msg'];
						this.tui.toast(resMsg);
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/point/order-list'
							});
						}, 1000);
					}
				});
			},	
			
		},
		
		//页面加载的时候
		onLoad: function(options) {
			this.orderId = options.id || 0;
			this.getOrderInfo();
		},
	}
</script>

<style>
	
	
	.container {
		padding-bottom: 98rpx;
	}

	.tui-box {
		padding: 0 0 118rpx;
		box-sizing: border-box;
	}

	.tui-address {
		min-height: 80rpx;
		padding: 10rpx 0;
		box-sizing: border-box;
		position: relative;
	}

	.tui-userinfo {
		font-size: 30rpx;
		font-weight: 500;
		line-height: 30rpx;
		padding-bottom: 12rpx;
	}

	.tui-name {
		padding-right: 40rpx;
	}

	.tui-addr {
		font-size: 24rpx;
		word-break: break-all;
		padding-right: 25rpx;
	}

	.tui-addr-tag {
		padding: 5rpx 8rpx;
		flex-shrink: 0;
		background: #EB0909;
		color: #fff;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		font-size: 25rpx;
		line-height: 25rpx;
		transform: scale(0.8);
		transform-origin: 0 center;
		border-radius: 6rpx;
	}

	.tui-bg-img {
		position: absolute;
		width: 100%;
		height: 8rpx;
		left: 0;
		bottom: 0;
		background: url("") repeat;
	}

	.tui-top {
		margin-top: 20rpx;
		overflow: hidden;
	}

	.tui-goods-title {
		font-size: 28rpx;
		display: flex;
		align-items: center;
	}

	.tui-padding {
		box-sizing: border-box;
	}

	.tui-goods-item {
		width: 100%;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
	}

	.tui-goods-img {
		width: 180rpx;
		height: 180rpx;
		display: block;
		flex-shrink: 0;
	}

	.tui-goods-center {
		flex: 1;
		padding: 20rpx 8rpx;
		box-sizing: border-box;
	}

	.tui-goods-name {
		max-width: 310rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		font-size: 26rpx;
		line-height: 32rpx;
	}

	.tui-goods-attr {
		font-size: 22rpx;
		color: #888888;
		line-height: 32rpx;
		padding-top: 20rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}

	.tui-price-right {
		text-align: right;
		font-size: 24rpx;
		color: #888888;
		line-height: 30rpx;
		padding-top: 20rpx;
	}

	.tui-flex {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 26rpx;
	}
	.tui-total-flex{
		justify-content: flex-end;
	}

	.tui-color-red,
	.tui-invoice-text {
		color: #E41F19;
		padding-right: 30rpx;
	}

	.tui-balance {
		font-size: 28rpx;
		font-weight: 500;
	}

	.tui-black {
		color: #222;
		line-height: 30rpx;
	}

	.tui-gray {
		color: #888888;
		font-weight: 400;
	}

	.tui-light-dark {
		color: #666;
	}

	.tui-goods-price {
		display: flex;
		align-items: center;
		padding-top: 20rpx;
	}

	.tui-size-26 {
		font-size: 26rpx;
		line-height: 26rpx;
	}

	.tui-price-large {
		font-size: 34rpx;
		line-height: 32rpx;
		font-weight: 600;
	}

	.tui-flex-end {
		display: flex;
		align-items: flex-end;
		padding-right: 0;
	}

	.tui-phcolor {
		color: #B3B3B3;
		font-size: 26rpx;
	}

	/* #ifndef H5 */
	.tui-remark-box {
		padding: 22rpx 30rpx;
	}

	/* #endif */
	/* #ifdef H5 */
	.tui-remark-box {
		padding: 26rpx 30rpx;
	}

	/* #endif */

	.tui-remark {
		flex: 1;
		font-size: 26rpx;
		padding-left: 64rpx;
	}

	.tui-scale-small {
		transform: scale(0.8);
		transform-origin: 100% center;
	}

	.tui-scale-small .wx-switch-input {
		margin: 0 !important;
	}

	/* #ifdef H5 */
	>>>uni-switch .uni-switch-input {
		margin-right: 0 !important;
	}

	/* #endif */
	.tui-tabbar {
		width: 100%;
		height: 98rpx;
		background: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		font-size: 26rpx;
		box-shadow: 0 0 1px rgba(0, 0, 0, .3);
		padding-bottom: env(safe-area-inset-bottom);
		z-index: 999;
	}

	.tui-pr-30 {
		padding-right: 30rpx;
	}

	.tui-pr-20 {
		padding-right: 20rpx;
	}

	.tui-none-addr {
		height: 80rpx;
		padding-left: 5rpx;
		display: flex;
		align-items: center;
	}

	.tui-addr-img {
		width: 36rpx;
		height: 46rpx;
		display: block;
		margin-right: 15rpx;
	}


	.tui-pr25 {
		padding-right: 25rpx;
	}

	.tui-safe-area {
		height: 1rpx;
		padding-bottom: env(safe-area-inset-bottom);
	}
	
	
	.tui-top-refund {
		width: 80%;
		margin-top: 80rpx;
		margin-left: 10%;
		overflow: hidden;
	}
	
	
	
	/*Model 弹窗*/
	.tui-modal-custom {
		text-align: center
	}

	.tui-modal-custom-text {
		font-size: 30rpx;
		color: #333;
		padding: 30rpx 0
	}

	.tui-prompt-title {
		padding-bottom: 20rpx;
		font-size: 34rpx;
	}

	.tui-input {
		margin: 30rpx 20rpx;
		border-bottom: 1rpx solid #E6E6E6;
		padding-bottom: 20rpx;
		font-size: 32rpx;
	}
	
	
	.tui-edit {
		margin-top: 160rpx;
		padding: 20rpx 100rpx;
		margin-bottom: 400rpx;
	}
	
	.tui-exit {
		margin-top: 20rpx;
		padding: 10rpx 100rpx;
		margin-bottom: 400rpx;
	}
</style>